<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<link rel="stylesheet"
	href="${initParam.root}/css/sunny/jquery-ui-1.9.2.custom.css" />
<script type="text/javascript"
	src="${initParam.root}/js/jquery-1.8.3.js"></script>
<script type="text/javascript"
	src="${initParam.root}/js/jquery-ui-1.9.2.custom.js"></script>
<link rel="stylesheet"
	href="${initParam.root }/css/member/main_updateMemberByAdmin.css" />

<script type="text/javascript">
$(function(){
		$("#a_anni1").datepicker({
			  dateFormat: "yy-mm-dd",
		         dayNamesMin: ['월', '화', '수', '목', '금', '토', '일'], // 요일의 한글 형식.
		         monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], // 월의 한글 형식.
		         showMonthAfterYear:true,
		         changeYear:true
		});
		$("#a_anni2").datepicker({
			  dateFormat: "yy-mm-dd",
		         dayNamesMin: ['월', '화', '수', '목', '금', '토', '일'], // 요일의 한글 형식.
		         monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], // 월의 한글 형식.
		         showMonthAfterYear:true,
		         changeYear:true
		});
		$("#goUpdateMember").click(function(){
			if($("#userPass").val()==""){
				alert("패스워드를 입력하세요");
				$("#userPass").focus();
				return;
			}else if($("#passConfirm").val()==""){
				alert("패스워드확인을 입력하세요");
				$("#passConfirm").focus();
				return;
			}else if($("#emailCheckResult").val()=="false"){
				alert("이메일 중복 체크하세요");
				return;
			}else if($("#userPass").val()!=$("#passConfirm").val()){
				alert("패스워드가 같지 않습니다");
				$("#userPass").val("");
				$("#passConfirm").val("");
				$("#userPass").focus();
				return;
			}else if($("#anniversary1").val()==""){
				alert("기념일을 선택하세요");
				return; 	
			}else if($("#a_anni").val()==""){
				alert("날짜를 입력하세요");
				return; 	
			}else if($("#anniversary2").val()==""){
				alert("기념일을 선택하세요");
				return; 	
			}else if($("#a_anni").val()==""){
				alert("날짜를 입력하세요");
				return; 	
			}			
			var flag=confirm("변경된 회원 정보를 수정하시겠습니까?");
			if(flag){
					$("#updateFormByAdmin").submit();
			}
		});  //click
		$("#emailCheck").click(function(){
			var email=$("#email").val();
			var portalSite=$("#portalSite").val();
			var userId=$("#userId").val();
			 	$.ajax({
				type:"POST",
				url : "${initParam.root}/member.do", 
				data : "command=emailCheckByAdmin&mEmail=" + email+"&mEmailPortalSite="+portalSite+"&m_id="+userId,
				dataType : "json",
				success : function(data) {
					if(data.flag.flagByAdmin==true){
						$("#checkEmail").html(email+"@"+portalSite+"는 사용가능한 email입니다.");
						$("#emailCheckResult").val("true");
					}else	 if(data.flag.flag==true){
							$("#checkEmail").html(email+"@"+portalSite+"는 동일한 email이 존재합니다.");
							$("#emailCheckResult").val("false");
					}else if(data.flag.flag==false){
						$("#checkEmail").html(email+"@"+portalSite+"는 사용가능한 email입니다.");
						$("#emailCheckResult").val("true");
					}else if(data.flag.fail==true){
						$("#checkEmail").html("이메일 입력란에 @를 사용할수 없습니다.");
						$("#emailCheckResult").val("false");
					}
					
				}//success:function
				
			}); //fucntion
		});//click
});		//load
		
</script>

<h3>
	<img alt="title"
		src="${initParam.root }/img/main/update/main-update-title.gif"
		id="title">
</h3>

<div id="회원수정">
	<form action="${initParam.root}/member.do" id="updateFormByAdmin"
		name="updateForm">
		<input type="hidden" name="command" value="updateMemberByAdmin">
		<input type="hidden" id="emailCheckResult" value="false">
		<ul id="회원정보1">
			<li><img alt="이름"
				src="${initParam.root }/img/main/update/main-update-name.gif"
				class="infoName"><input type="text" name="m_name"
				id="userName" value="${requestScope.getMemberInfo.memInfo.m_name }"></li>
			<li><img alt="아이디"
				src="${initParam.root }/img/main/update/main-update-id.gif"
				class="infoId"><input type="text" name="m_id" id="userId"
				value="${requestScope.getMemberInfo.memInfo.m_id }"
				readonly="readonly"></li>
			<li><img alt="주민등록번호"
				src="${initParam.root }/img/main/update/main-update-ssn.gif"
				class="infoSsn"> <img alt="14"
				src="${initParam.root }/img/main/update/main-update-14.jpg"></li>
			<li><img alt="이메일"
				src="${initParam.root }/img/main/update/main-update-email.gif"
				class="infoEmail"><input type="text" name="m_email" id="email"
				value="${requestScope.getMemberInfo.memEmailF }">@ <select
				id="portalSite" name="mEmailPortalSite">
					<option value="${requestScope.getMemberInfo.memEmailT }">${requestScope.getMemberInfo.memEmailT
						}</option>
					<option value="naver.com">naver.com</option>
					<option value="nate.com">nate.com</option>
					<option value="dreamwiz.com">dreamwiz.com</option>
					<option value="yahoo.com">yahoo.com</option>
					<option value="empal.com">empal.com</option>
					<option value="gmail.com">gmail.com</option>
					<option value="korea.com">korea.com</option>
					<option value="chol.com">chol.com</option>
					<option value="freechal.com">freechal.com</option>
					<option value="daum.net">daum.net</option>
					<option value="hotmail.com">hotmail.com</option>
			</select> <input type="button" value="이메일중복체크" id="emailCheck"></li>
			<li><span id="checkEmail"></span></li>
			<li><img alt="비밀번호"
				src="${initParam.root }/img/main/update/main-update-password.gif"
				class="infoPass"><input type="text" name="m_password"
				id="userPass"
				value="${requestScope.getMemberInfo.memInfo.m_password }"> <img
				alt="비밀번호확인"
				src="${initParam.root }/img/main/update/main-update-repassword.gif"
				class="infoPassConfirm"><input type="text" name="passConfirm"
				id="passConfirm" value=""></li>
			<li><img alt="정보"
				src="${initParam.root }/img/main/update/main-update-info.gif"
				class="info"></li>
		</ul>
		<hr>
		<ul id="회원정보2">
			<li><img alt="관심요리"
				src="${initParam.root }/img/main/update/main-update-favorite.gif"
				id="관심요리"></li>
			<c:choose>
				<c:when
					test="${requestScope.getMemberInfo.memInfo.m_likeCook=='한식'}">
					<li><input type="radio" name="m_likeCook" value="한식"
						name="m_likeCook" checked="checked" value="한식">한식 <input
						type="radio" name="m_likeCook" value="일식" name="m_likeCook"
						value="일식">일식 <input type="radio" name="m_likeCook"
						value="중식" name="m_likeCook" value="중식">중식 <input
						type="radio" name="m_likeCook" value="양식" name="m_likeCook"
						value="양식">양식</li>
				</c:when>
				<c:when
					test="${requestScope.getMemberInfo.memInfo.m_likeCook=='일식'}">
					<li><input type="radio" name="m_likeCook" value="한식"
						name="m_likeCook" value="한식">한식 <input type="radio"
						name="m_likeCook" value="일식" name="m_likeCook" checked="checked"
						value="일식">일식 <input type="radio" name="m_likeCook"
						value="중식" name="m_likeCook" value="중식">중식 <input
						type="radio" name="m_likeCook" value="양식" name="m_likeCook"
						value="양식">양식</li>
				</c:when>
				<c:when
					test="${requestScope.getMemberInfo.memInfo.m_likeCook=='중식'}">
					<li><input type="radio" name="m_likeCook" value="한식"
						name="m_likeCook" value="한식">한식 <input type="radio"
						name="m_likeCook" value="일식" name="m_likeCook" value="일식">일식
						<input type="radio" name="m_likeCook" value="중식" name="m_likeCook"
						checked="checked" value="중식">중식 <input type="radio"
						name="m_likeCook" value="양식" name="m_likeCook" value="양식">양식
					</li>
				</c:when>
				<c:otherwise>
					<li><input type="radio" name="m_likeCook" value="한식"
						name="m_likeCook" value="한식">한식 <input type="radio"
						name="m_likeCook" value="일식" name="m_likeCook" value="일식">일식
						<input type="radio" name="m_likeCook" value="중식" name="m_likeCook"
						value="중식">중식 <input type="radio" name="m_likeCook"
						value="양식" name="m_likeCook" checked="checked" value="양식">양식
					</li>
				</c:otherwise>
			</c:choose>

			<li><img alt="결혼유무"
				src="${initParam.root }/img/main/update/main-update-married.gif"
				id="결혼유무"></li>
			<%-- ${requestScope.mvo.m_married} --%>
			<c:choose>
				<c:when test="${requestScope.getMemberInfo.memInfo.m_married=='기혼'}">
					<li><input type="radio" value="미혼" name="m_married">미혼
						<input type="radio" value="기혼" name="m_married" checked="checked">기혼
					</li>
				</c:when>
				<c:otherwise>
					<li><input type="radio" value="미혼" name="m_married"
						checked="checked">미혼 <input type="radio" value="기혼"
						name="m_married">기혼</li>
				</c:otherwise>
			</c:choose>

			<li><img alt="성별"
				src="${initParam.root }/img/main/update/main-update-gender.gif"
				id="성별"></li>
			<c:choose>
				<c:when test="${requestScope.getMemberInfo.memInfo.m_gender=='f'}">
					<li><input type="radio" name="m_gender" value="m">남 <input
						type="radio" name="m_gender" value="f" checked="checked">여
					</li>
				</c:when>
				<c:otherwise>
					<li><input type="radio" name="m_gender" value="m"
						checked="checked">남 <input type="radio" name="m_gender"
						value="f">여</li>
				</c:otherwise>
			</c:choose>

			<li><img alt="기념일"
				src="${initParam.root }/img/main/update/main-update-anniversary.gif"
				id="기념일"></li>
			<c:forEach items="${requestScope.getMemberInfo.anniInfo }" var="anni">
				<li><select id="anniversary${anni.a_no }"
					name="anniversary${anni.a_no }">
						<c:choose>
							<c:when test="${anni.a_kind=='기념일' }">
								<option value="">---</option>
								<option value="생일">생일</option>
								<option value="기념일" selected="selected">기념일</option>
							</c:when>
							<c:otherwise>
								<option value="">---</option>
								<option value="생일" selected="selected">생일</option>
								<option value="기념일">기념일</option>
							</c:otherwise>
						</c:choose>
				</select> 기념일 날짜 <input type="text" name="a_date${anni.a_no }"
					value="${anni.a_date}" id="a_anni${anni.a_no }"></li>
			</c:forEach>
			<li><input type="button" value="수정하기" id="goUpdateMember"
				class="button_img"></li>
		</ul>
	</form>
</div>